//
//  MeIndexCell.m
//  BrotherMovProject
//
//  Created by zhibao on 2021/12/17.
//

#import "MeIndexCell.h"
@interface MeIndexCell(){
    UIImageView *imgView;
    UILabel *nameLabel;
    UILabel *detailLabel;
}
@end

@implementation MeIndexCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //self.contentView.backgroundColor = ThemeColor;
        nameLabel = [[UILabel alloc]init];
        nameLabel.font = MY_SCALE_RegularFONT(14);
        nameLabel.textColor = UIColor.blackColor;
        [self.contentView addSubview:nameLabel];
        [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(60);
            make.top.bottom.equalTo(self.contentView);
            make.height.mas_equalTo(54);
        }];
        
        imgView = [[UIImageView alloc]init];
        [self.contentView addSubview:imgView];
        [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(30);
            make.centerY.equalTo(nameLabel);
        }];
        
        UIImageView *rightImgView = [[UIImageView alloc]init];
        rightImgView.image = [UIImage imageNamed:@"me_index_right"];
        [self.contentView addSubview:rightImgView];
        [rightImgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView).offset(-30);
            make.centerY.equalTo(nameLabel);
        }];
        
        detailLabel = [[UILabel alloc]init];
        detailLabel.font = MY_SCALE_FONT(12);
        detailLabel.textColor = MyColor(@"999999");
        [self.contentView addSubview:detailLabel];
        [detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(rightImgView.mas_left).offset(-4);
            make.centerY.equalTo(nameLabel);
            make.height.mas_equalTo(54);
        }];
        
        UIView *line = [UIView new];
        line.backgroundColor = MyColor(@"#EEEEEE");
        [self.contentView addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(30);
            make.right.mas_equalTo(-30);
            make.bottom.equalTo(self.contentView);
            make.height.mas_equalTo(0.5);
        }];
    }
    return self;
}

- (void)update:(NSDictionary *)dic{
    imgView.image = [UIImage imageNamed:dic[@"img"]];
    nameLabel.text = dic[@"name"];
    detailLabel.text = dic[@"detail"];
    if([nameLabel.text isEqualToString:LocalizedString(@"福利社")]){
        nameLabel.textColor = MyColor(@"#FF9F04");
        detailLabel.textColor = MyColor(@"#FF9F04");
        nameLabel.font = MY_SCALE_SemiboldFONT(14);
        detailLabel.font = MY_SCALE_SemiboldFONT(12);
    }else{
        nameLabel.textColor = UIColor.blackColor;
        detailLabel.textColor = MyColor(@"999999");
        nameLabel.font = MY_SCALE_RegularFONT(14);
        detailLabel.font = MY_SCALE_FONT(12);
    }
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
